package model;

import java.util.ArrayList;
import java.util.List;

public class Word implements Comparable<Word> {

	private String word;
	private String theme;
	private  List<String> syllables;
	
	
	public Word(String word, String theme) {
		this.word=word;
		this.setTheme(theme);
		setSyllables(new ArrayList<String>());
	}

	/**
	 * 
	 * @param word
	 * @param theme
	 * @param syllables
	 */
	public Word(String word, String theme,List<String> syllables) {
		this(word, theme);
		this.syllables=syllables;
	}
	/**
	 * 
	 * @param syllable
	 * @return
	 */
	public boolean addSyllable(String syllable){
		return syllables.add(syllable);
	}
	
	/**
	 * @param word the word to set
	 */
	public void setWord(String word) {
		this.word = word;
	}

	/**
	 * @return the word
	 */
	public String getWord() {
		return word;
	}

	/**
	 * @param theme the theme to set
	 */
	public void setTheme(String theme) {
		this.theme = theme;
	}

	/**
	 * @return the theme
	 */
	public String getTheme() {
		return theme;
	}

	@Override
	public int compareTo(Word w) {
		return this.word.compareTo(w.word);
	}

	/**
	 * @param syllables the syllables to set
	 */
	public void setSyllables(List<String> syllables) {
		this.syllables = syllables;
	}

	/**
	 * @return the syllables
	 */
	public List<String> getSyllables() {
		return syllables;
	}
	
	
	/**
	 * 
	 */
	public boolean equals(Object otherObject) {
		
		if(!(otherObject instanceof String) )
			return false;
		String s=(String)otherObject;
		return this.getWord().equals(s);
		
	}
	
	@Override
	public String toString(){
		
		StringBuilder sb=new StringBuilder();
		
		sb.append(this.word+":");
		for(String s:syllables)
			sb.append(s);
		return sb.toString()+"\n";
		/*
		String line1=this.word+":";
		for(String s:syllables) 
			line1+=s+" ";
		return line1+"\n";*/
	}

}
